home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 10 / FM Towns Free Software Collection 10.iso / ms_dos / tool / conhlp03 / fswchsrc / keyword.c < prev    next >
Text File  |  1994-11-16  |  1KB  |  67 lines

  1. /*
  2.     keyword.c
  3.     キーワードの処理関数
  4. */
  5.  
  6. #include <stdlib.h>
  7. #include "fswch.h"
  8.  
  9. int split( char *s, char **str, const char *sep); /* 文字の切り分け */
  10.  
  11. void dispkeyword( void ){/* キーワード表示 */
  12.     int i,j,cpro;
  13.     /* KEYWORD 表示 と カウント */
  14.     clstext();
  15.     cputs(  ESC_SKYBULE"===== KEYWORD =====  "
  16.         ESC_WHITE"[白:選択] "
  17.         ESC_YELLOW"[黄:否定選択]\r\n");
  18.     for(i=0;i<kno;i++){
  19.         for(cpro=j=0;j<ino;j++)
  20.             if(idxpkey[j][i]==ON) cpro++;
  21.         cputs( (skey[i]==SELLECT) ? ESC_WHITE :
  22.             (skey[i]==NONSELLECT) ? ESC_YELLOW :
  23.             ESC_RED );
  24.         cprintf( "[%2d:%-10.10s%4d]",i,keyword[i],cpro);
  25.         if(((i+1)%4)==0) cputs("\r\n");
  26.     }
  27.     cputs( ESC_WHITE );
  28. }
  29.  
  30. int chekkeyword( void ){/* 作品選択チェック */
  31.     int i,j,cpro;
  32.     for(cpro=i=0;i<ino;i++){
  33.         int cc;
  34.         for(cc=j=0;j<kno;j++){
  35.             if(idxpkey[i][j]!=ON) continue;
  36.             if(skey[j]==SELLECT ){
  37.                 cc++;
  38.             }else
  39.             if(skey[j]==NONSELLECT){
  40.                 cc=0;
  41.                 break;
  42.             }
  43.         }
  44.         if(cc==0 || cc!=ckey) continue;
  45.         selprog[cpro++]=i;
  46.     }
  47.     if(cpro==0) return -1;
  48.     return cpro;
  49. }
  50.  
  51. void setkf( char *s ){ /* キーフラグにセット */
  52.     int c,i;
  53.     char *str[10];
  54.     c = split(s+1,str,",/");
  55.     for(i=0;i<c;i++){
  56.         int no;
  57.         no=atoi(str[i]);
  58.         if( no < 0 || no >= KEY_MAX ) continue;
  59.         if( *s == '+' ){
  60.             skey[no] = SELLECT ;
  61.             ckey++;
  62.         } else {
  63.             skey[no] = NONSELLECT ;
  64.         }
  65.     }
  66. }
  67.